<?php

namespace App\Http\Controllers\Web;

//基础控制器
use App\Http\Controllers\Controller;
//
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;

use App\Repositories\OrderQueueRepository;


class QueueController extends Controller
{
    protected $queue;
    public function __construct(OrderQueueRepository $queue)
    {
        $this->queue = $queue;
    }

    public function createQueueOrder(Request $request)
    {
        $rules = [
            'shop_id' => 'required',
            'eat_time' => 'required',
            'people' => 'required',
            'type' => 'required',
        ];
        $validator = Validator::make($request->all(), $rules);
        if ($validator->fails()) {
            return show(201,  $validator->errors()->first());
        }
        return $this->queue->createQueueOrder($request);
    }

    //排队订单
    public function showQueueOrder()
    {
        return $this->queue->showQueueOrder();
    }

    //排队信息
    public function showQueueMessage(Request $request)
    {
        $rules = [
            'shop_id' => 'required',
        ];
        $validator = Validator::make($request->all(), $rules);
        if ($validator->fails()) {
            return show(201, $validator->errors()->first());
        }
        return $this->queue->showQueueMessage($request);
    }

}
